using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace NUnitHelper
{
    public partial class DataManagerHelper : Form
    {
        public DataManagerHelper()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (dlgFile.ShowDialog(this) == DialogResult.OK)
            {
                txtFileName.Text = dlgFile.FileName;
            }

            lstTables.Items.Clear();
            foreach (string s in Managers.DataManagerTemplate.GetListOfTables(dlgFile.FileName))
            {
                lstTables.Items.Add(s);
            }
        }

        private void lstTables_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstTables.Text.Length > 0)
            {
                UpdateWindow();
            }
        }

        private void UpdateWindow()
        {
            txtClass.Text = Managers.DataManagerTemplate.GetDataManagerClass(lstTables.Text);

            txtClass.Focus();
            txtClass.SelectAll();
        }
    }
}